import api from './index'

export const logApi = {
  // 获取日志列表
  getLogs(params) {
    return api.get('/logs/', { params })
  },

  // 获取日志详情
  getLog(id) {
    return api.get(`/logs/${id}`)
  },

  // 下载日志文件
  downloadLogs(params) {
    return api.get('/logs/export/download', {
      params,
      responseType: 'blob'
    })
  },

  // 提交日志导出任务
  exportLogs(params) {
    return api.post('/logs/export', null, { params })
  },

  // 获取日志统计信息
  getLogStatistics(params) {
    return api.get('/logs/statistics', { params })
  },

  // 清理过期日志
  cleanupOldLogs(retentionDays = 30) {
    return api.post('/logs/cleanup', null, { params: { retention_days: retentionDays } })
  },

  // 获取所有日志级别
  getLogLevels() {
    return api.get('/logs/levels')
  },

  // 获取所有日志步骤
  getLogSteps() {
    return api.get('/logs/steps')
  },

  // 生成日志报告
  generateLogReport(params) {
    return api.post('/logs/report', null, { params })
  },

  // 归档日志
  archiveLogs(params) {
    return api.post('/logs/archive', null, { params })
  },

  // 搜索日志
  searchLogs(params) {
    return api.get('/logs/search', { params })
  }
}